package com.amsp.oa.oademo.service.impl;

import com.amsp.oa.oademo.entity.LaborTermination;
import com.amsp.oa.oademo.mapper.LaborTerminationMapper;
import com.amsp.oa.oademo.service.LaborTerminationService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class LaborTerminationServiceImpl extends ServiceImpl<LaborTerminationMapper, LaborTermination>
        implements LaborTerminationService {

    @Override
    public IPage<LaborTermination> getPage(Integer current, Integer size, String bParty) {
        Page<LaborTermination> page = new Page<>(current, size);
        LambdaQueryWrapper<LaborTermination> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(bParty)) {
            wrapper.like(LaborTermination::getBParty, bParty);
        }

        wrapper.orderByDesc(LaborTermination::getCreateTime);
        return this.page(page, wrapper);
    }
}